import React, { useEffect, useState } from 'react';
import { Modal, Table } from 'dw-mx';
import { request } from 'dw-mx-request';
const { Column } = Table;

export default function Lov(props) {
    const [dataSource, updateDataSource] = useState([]);

    useEffect(() => {
        queryKsLovInfo();
    }, []);

    const queryKsLovInfo = async () => {
        const ret = await request('/mock/xcjdwh/queryKsInfo', {
            ksbh: props.ksbh,
        });
        updateDataSource(ret.ksinfo);
    };
    return (
        <Modal title="请选择" visible={true} footer={null} onCancel={() => props.closeModal()} width={'400px'}>
            <Table
                scroll={{ x: '100%', y: '500px' }}
                dataSource={dataSource}
                pagination={false}
                bordered
                rowKey={'ksbh'}
                onRow={(record: any, index) => {
                    return {
                        onDoubleClick: () => {
                            props.closeModal({ksmc:record.ksmc});
                        },
                    };
                }}
            >
                <Column ellipsis={true} title="序号" dataIndex="ksbh" key="ksbh" width={'30%'} />
                <Column ellipsis={true} title="科室名称" dataIndex="ksmc" key="ksmc" width={'30%'} />
            </Table>
        </Modal>
    );
}